package demo.ClassLoad;

import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
import java.lang.reflect.Method;

/**
 * @Auther: hjy(lc))
 * @Date: 2022/8/5-08-05-14:44
 * @Description：demo.ClassLoad
 */

@WebServlet("/user/*")
public class UserAddServlet extends BaseSevlet {
    @Override
    public void service(String assessUrl) throws Exception {
        // 取/*的值  反射调用对应的方法
        Class c = Class.forName("demo.ClassLoad.UserAddServlet");
        Method method = c.getDeclaredMethod(assessUrl);
        method.invoke(c.newInstance(),null);
    }

    public void add() {
        System.out.println("UserAddServlet.add");
        System.out.println("添加______________________");
    }



    public void update() {
        System.out.println("UserAddServlet.update");
        System.out.println("更新——————————————————————");
    }


    public void show() {
        System.out.println("UserAddServlet.show");
        System.out.println("展示——————————————————————");
    }
}

@Target({ElementType.TYPE,ElementType.METHOD})
@Retention(RetentionPolicy.RUNTIME)
@interface WebServlet{
    String value();
}

